﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HRM.BLL;

namespace HRM.UI.HRAdminUI.AttendenceUI
{
    public partial class UploadAttendance : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void ExportFile(object o,EventArgs e)
        {
            try
            {
                string filepath = fileuploadExcel.PostedFile.FileName;
                //fileuploadExcel.PostedFile.SaveAs(Server.MapPath("~/AttendanceSheet/") + filepath);
                AttendanceManager manager = new AttendanceManager();
                filepath = @"G:\\att\\" + filepath;
                if(manager.SaveAttendance(filepath))
                {
                    msgLbl.ForeColor = Color.Green;
                    msgLbl.Text = "Attendance Sheet Uploaded into Database Successfully";
                }
                else
                {
                    msgLbl.ForeColor = Color.Red;
                    msgLbl.Text = "An Error Occured During Uploaded Attendance Sheet into Database";
                }
            }
            catch (Exception ex)
            {
                msgLbl.ForeColor = Color.Red;
                msgLbl.Text = ex.Message;
            }
        }
        protected void ClearAttendance(object o,EventArgs e)
        {
            try
            {
                AttendanceManager manager = new AttendanceManager();
                if(manager.ClearAttendanceInfo())
                {
                    clearMsgLbl.ForeColor = Color.Green;
                    clearMsgLbl.Text = "Successfully Clear All Previous Attendance Information";
                }
                else
                {
                    clearMsgLbl.ForeColor = Color.Red;
                    clearMsgLbl.Text = "Not Clear Information, Try again !";
                }
            }
            catch (Exception ex)
            {
                clearMsgLbl.ForeColor = Color.Red;
                clearMsgLbl.Text = ex.Message;
            }
        }
    }
}